<%@page pageEncoding = "utf-8" contentType = "text/html;charset=utf-8"%>

<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>

<script type="text/javascript">
window.onload = function () {
  enddate  = new Epoch('epoch_popup','popup',document.getElementById('enddate'));
};
</script>

<h2>Изменить заявку</h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<form action = "chiefui" method = "post" name = "requestEditForm">
   <table class = "form"> 
                                
      <tr>
         <td class = "label">
           Текст заявки<br>
           <span class="small">(Заполняется клиентом)</span>
         </td>
         <td>
            <textarea name = "text" rows="10" cols="50"><c:out value = "${requestBean.clientText}"/></textarea>
         </td>
      </tr>     
      
      <tr>
         <td class = "label">
           Текст заявки<br> 
           <span class="small">(Заполняется руководителем)</span><span class="star">*</span>
         </td>
         <td>
            <textarea name = "dispatcherText" rows="10" cols="50"><c:out value = "${requestBean.dispatcherText}"/></textarea>
            <span class="error"><c:out value="${error.dispatcherText}"/></span>
         </td>
      </tr>             
      
      <tr>
         <td class = "label"><fmt:message key = "request.requestType"/><span class="star">*</span></td>
         <td>
            <select name="requesttype_id">              
              <c:forEach var = "requestType" items = "${requestTypesList}">
                <option value="${requestType.id}" ${requestType.id == requestBean.requestTypeId ? "selected" : ""}>
                   <c:out value="${requestType.type}"/>
                </option>
              </c:forEach>
            </select>            
            <span class="error"><c:out value="${error.requestType}"/></span>
         </td>
      </tr>

      <tr>
         <td class = "label"><fmt:message key = "request.approxEndDate"/><span class="star">*</span></td>
         <td>
            <input class="date" id="enddate" type="text" name="approxEndDate" value='<fmt:formatDate value="${requestBean.approxEndDate}" pattern="dd.MM.yyyy"/>'/>          
            <span class="error"><c:out value="${error.approxEndDate}"/></span>
         </td>
      </tr>

      <tr>
         <td class = "label"><fmt:message key = "request.priority"/><span class="star">*</span></td>
         <td>
            <ul class="simple"> 
            <c:forEach var = "priority" items = "${priorityList}">
               <li>
                  <input type="radio" name="priority" value="${priority.id}" ${priority.id == requestBean.priority ? "checked" : ""}/>
                  ${priority.value}
               </li>            
            </c:forEach>
            <span class="error"><c:out value="${error.priority}"/></span>
            </ul>
         </td>
      </tr>
      
      <tr>
         <td class = "label"><fmt:message key = "request.comment"/></td>
         <td>
            <textarea name = "comment" rows="10" cols="50"><c:out value = "${requestBean.comment}"/></textarea>
         </td>
      </tr>
</table>

<input name = "_action" type = "hidden" value="updateRequest">
<input name="id" type="hidden" value="${requestBean.id}">

<p>Обязательные для заполнения поля отмечены <span class="star">*</span></p>

<p>
<input type="submit" value='<fmt:message key = "Command.save"/>' onclick="return confirm('Вы действительно хотите сохранить изменения?')">
или
<a href = "chiefui?_action=dumb">
  <fmt:message key = "Command.RequestList"/>
</a> 
</p>

</form>